# _*_ coding utf-8 _*_
# FILENAME：orderPlan.py
# DESCRIPTION: 排单模型
# AUTH: jarvis zhang
# DATE: 2022/6/2 10:00 下午

from sqlalchemy import Column, String, Integer, DECIMAL, Text

from models.baseModel import BaseModel


# 排单主表
class OrderPlanModel(BaseModel):
    # 表的名字:
    __tablename__ = 'order_plan'
    # 表的结构:
    version_name = Column(String(255), index=True, comment='版本名称')
    shipper_version_id = Column(Integer, comment='承运商版本编号')
    supplier_address_version_id = Column(Integer, comment='供应商地址版本编号')
    supplier_distance_version_id = Column(Integer, comment='供应商距离版本编号')
    supplier_duration_version_id = Column(Integer, comment='供应商路程时间版本编号')
    operation_time_version_id = Column(Integer, comment='作业时间版本编号')
    factory_transport_time_version_id = Column(Integer, comment='厂内运行时间版本编号')
    algorithm_id = Column(Integer, comment='算法ID')
    status = Column(Integer, comment='运算状态：1：待运算 2：运算中 3：运算成功 4：运算失败')
    loading_percentage = Column(DECIMAL(4, 2), comment='平均装载率')
    cost = Column(String(32), comment='总路程成本')
    trip_number = Column(Integer, comment='总趟数')
    van_enough = Column(Integer, comment='车辆是否充足 0:不充足 1:充足')
    version_desc = Column(Text, comment='版本描述')
    # 添加表注释
    __table_args__ = ({'comment': '排单主表'})


## 排单-库存表
class OrderPlanInventoryModel(BaseModel):
    # 表的名字:
    __tablename__ = 'order_plan_inventory'
    # 表的结构:
    order_plan_id = Column(Integer, index=True, comment='排单计划编号')
    inventory_version_id = Column(Integer, comment='库存版本编号')
    # 添加表注释
    __table_args__ = ({'comment': '排单库存关联表'})

## 排单-库存表
class OrderPlanPartsModel(BaseModel):
    # 表的名字:
    __tablename__ = 'order_plan_parts'
    # 表的结构:
    order_plan_id = Column(Integer, index=True, comment='排单计划编号')
    parts_version_id = Column(Integer, comment='零件版本编号')
    # 添加表注释
    __table_args__ = ({'comment': '排单零件关联表'})


# 排单详情表
class OrderPlanDetailsModel(BaseModel):
    # 表的名字:
    __tablename__ = 'order_plan_details'
    # 表的结构:
    order_plan_id = Column(Integer, index=True, comment='排单计划编号')
    van_code = Column(String(32), comment='货车编号')
    van_size = Column(String(32), comment='物流车型')
    supplier_name = Column(String(64), comment='供应商名称')
    supplier_address = Column(String(255), comment='供应商地址')
    parts_code = Column(String(32), comment='零件编号')
    parts_name = Column(String(64), comment='零件名称')
    parts_quantity = Column(Integer, comment='零件数量')
    parts_box_quantity = Column(Integer, comment='箱数')
    parts_snp = Column(Integer, comment='单包装容量')
    parts_packaging_type = Column(String(16), comment='包装类型')
    factory = Column(String(64), comment='目的地工厂')
    unloading_crossing = Column(String(16), comment='交付道口')
    distance = Column(DECIMAL(10, 2), comment='路程距离')
    loading_percentage = Column(DECIMAL(4, 2), comment='装载率')
    cost = Column(String(32), comment='路程成本')
    trip_number = Column(Integer, comment='趟数')
    arrival_time = Column(String(32), comment='预计抵达时间 格式2022-05-13 08:00:00')
    # 添加表注释
    __table_args__ = ({'comment': '排单详情表'})